package cn.edu.scau.cmi.chensixiao.composite.consistent;

import java.util.ArrayList;


public class ConsistentComposite extends ConsistentComponent{
	public ArrayList<ConsistentComponent> children = new ArrayList<ConsistentComponent>();
	
	@Override
	public String showMessage() {
		return "We are a Consistent organization:"+ this.name;
	}
	public ConsistentComposite(String name) {
		this.name = name;
	}
	
	public String addChild(ConsistentComponent child) {
		children.add(child);
		return child.name + "  添加成功";
	}
	
	public String delChild(int index) {
		if(!children.isEmpty()) {
			ConsistentComponent child = children.get(index);
			children.remove(index);
			return child.name + "  删除成功";
		}
		return "没有成员可删除";
	}
	public ArrayList<ConsistentComponent>getChildren(){
		return children;
	}
	
}
